import { defineConfig, loadEnv } from "vite";
import uni from "@dcloudio/vite-plugin-uni";
import WindiCSS from "vite-plugin-windicss";
import MiniProgramTailwind from "@dcasia/mini-program-tailwind-webpack-plugin/rollup";
import * as path from "path";
// https://vitejs.dev/config/
export default defineConfig(({ command, mode }) => {
  // 根据当前工作目录中的 `mode` 加载 .env 文件
  // 设置第三个参数为 '' 来加载所有环境变量，而不管是否有 `VITE_` 前缀。
  const env = loadEnv(mode, process.cwd(), "");
  return {
    define: {
      "process.env": {
        ...env,
      },
    },
    resolve: {
      alias: {
        "@": path.resolve(__dirname, "src"),
        "@images": path.resolve(__dirname, "src/static/images"),
        "@icons": path.resolve(__dirname, "src/static/icons"),
      },
    },
    plugins: [uni(), WindiCSS(), MiniProgramTailwind()],
  };
});
